package org.saxion.aktiehuis.DAO;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.saxion.aktiehuis.DAO.interfaces.ProductSoortDAO;
import org.saxion.aktiehuis.model.ProductSoort;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class ProductSoortMock extends HibernateDaoSupport implements ProductSoortDAO {
	
//
//	private SessionFactory sessionFactory;
//
//	
//	public void setSessionFactory(SessionFactory sessionFactory) {
//		this.sessionFactory = sessionFactory;
//	}

	/**
	 * 
	 */
	public List<ProductSoort> getProductSoorten() throws Exception {
		Session session = getSession(true);
		List<ProductSoort> test = null;
		try {
			Query query = session
					.createQuery("from ProductSoort");
			test = query.list();			
		} catch (Exception ex) {
			throw ex;
		}

		if (test != null) {
			return test;
		} else {
			return null;
		}
	}

	public void addProductSoort(String productSoortNaam) throws Exception {
		try
		{
			Session session = getSession(true);
			ProductSoort ps = new ProductSoort();
			ps.setNaam(productSoortNaam);
			session.save(ps);
			session.flush();
		}
		catch(Exception ex)
		{
			throw ex;
		}
		
	}

	
	
}
